<?php
require __DIR__ . '/core/System.php';

// 加载配置
$config = require SF_LIBRARY_PATH . 'Config.php';

$appConfig = file_exists($appConfigPath = SF_APP_PATH . 'Config.php') ? require $appConfigPath : [];
$config = array_merge($config, $appConfig);

if ($config['debug']) {
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);
}
// composer自动加载
require __DIR__ . '/vendor/autoload.php';

header("Content-Type: text/html; charset=utf-8");
// 允许所有域名访问
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: *');
session_id("wangcl");
session_start();
if (isset($_GET["name"])) {
    $c_str = $_REQUEST['name'] ?? 'Test';
    $a_name = $_REQUEST['method'] ?? 'test';
    require("$c_str.php");
    $controller = new $c_str();
    $controller->$a_name();
} else {
    $app = new Core\Application(new Core\Https\Request(), $config);
    $app->run();
}

